// pages/live/live.js
const app = getApp() 
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  // app.json配置
  // "plugins": {
  //   "live-player-plugin": {
  //     "version": "1.0.13",
  //     "provider": "wx2b03c6e691cd7370"
  //   }
  // },

  getRoom(){
    let that = this;
    wx.request({
      url: 'https://uplus.zhibang.com/index.php?s=/api/Video/getRoom',
      method: "post",
      data: {
        uid: 10017
      },
      success: function (res) {
        that.setData({
          liveList: res.data.data.list.room_info
        })
      }
    })
  },

  goLive(e){
    let that = this;
    let roomArr = [];
    roomArr.push(that.data.liveList[e.currentTarget.dataset.index]['roomid'])
    let roomId = roomArr;
    console.log(roomId);
    console.log(that.data.liveList);
    console.log(e.currentTarget.dataset.index);
    let customParams = { }
    wx.navigateTo({
      url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${encodeURIComponent(JSON.stringify(customParams))}`
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    // 获取直播房间号
    that.getRoom()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})